package com.ccys.cms.controller.masterData;

import com.ccys.cms.service.masterData.LanguageService;
import com.ccys.common.vo.ResponseResult;
import com.ccys.db.dto.masterData.LanguageDelDto;
import com.ccys.db.dto.masterData.LanguagePageDto;
import com.ccys.db.dto.masterData.LanguageSaveDto;
import com.ccys.db.vo.masterData.LanguageListVo;
import com.ccys.db.vo.masterData.LanguagePageQueryVo;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @program: WhiteCoat
 * @description: 语言接口
 * @author: ZhangJingCan
 * @create: 2023-12-11 09:07
 **/

@RestController
@RequestMapping("masterData")
@Api(tags = "masterData-语言接口")
public class LanguageController {

    @Autowired
    private LanguageService languageService;


    @PostMapping("language")
    @ApiOperation("保存语言")
    public ResponseResult save(LanguageSaveDto dto) {
        return languageService.save(dto);
    }

    @PutMapping("language")
    @ApiOperation("修改语言")
    public ResponseResult edit(LanguageSaveDto dto) {
        return languageService.save(dto);
    }

    @PutMapping("language/status")
    @ApiOperation("根据ID修改状态")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "对象id", required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "status", value = "状态：0-禁用，1-启用", required = true, dataType = "string", paramType = "query"),
    })
    public ResponseResult updateStatus(LanguageSaveDto dto) {
        return languageService.updateStatus(dto);
    }


    @DeleteMapping("language")
    @ApiOperation("根据ID删除语言")
    public ResponseResult deleteLanguageById(LanguageDelDto dto) {
        return languageService.deleteLanguageById(dto);
    }


    @GetMapping("language")
    @ApiOperation("分页查询语言")
    public ResponseResult<PageInfo<LanguagePageQueryVo>, Object> findPage(LanguagePageDto dto) {
        return languageService.findPage(dto);
    }

    @GetMapping("language/list")
    @ApiOperation("查询语言列表")
    public ResponseResult<List<LanguageListVo>, Object> findList() {
        return languageService.findList();
    }


}
